Skip to main content

matchChunk

Type

function

Summary

Returns true if the regex pattern pattern is found in the specified string, false otherwise.

Syntax

matchChunk(<string>, <pattern> [, <positionVarsList>])

Description

Use the matchChunk function to check whether a string contains a specified regex pattern.

If the pattern includes a pair of parentheses, the position of the substring matching the part of the pattern inside the parentheses is placed in the variables in the positionVarsList. The number of the first character in the matching substring is placed in the first variable in the positionVarsList, and the number of the last character is placed in the second variable. Additional starting and ending positions, matching additional parenthetical expressions, are placed in additional pairs of variables in the positionVarsList. If the matchChunk function returns false, the values of the variables in the positionVarsList are not changed.

The string and pattern are always case-sensitive, regardless of the setting of the caseSensitive property. (If you need to make a case-insensitive comparison, use "(?i)" at the start of the pattern to make the match case-insensitive.)

Important

Variables in the positionVarsList must be created before the matchChunk function is called. The matchChunk function, unlike the put command, does not create them automatically.

The matchChunk and matchText functions return the same value, given the same string and pattern. The difference between the two is that the matchChunk function records the positions of matched substrings in the optional positionVarsList variables, while the matchText function records the substrings themselves.

Parameters

NameTypeDescription

string

string

pattern

Any expression that evaluates to a regex pattern

positionVarsList

The optional positionVarsList consists of an even number of existing variables, separated by commas.

Examples

matchChunk("Hello","Hel") -- returns true
matchChunk("Hello","o$") -- also returns true
matchChunk(the short name of this stack,"^rev") -- starts with "rev"
matchChunk(field "Title",myExpr,startMatch,endMatch)

command: put, filter

constant: return

control structure: function

function: matchText, value

glossary: property, return, variable, value, call, regex pattern, case-sensitive, case-insensitive, function, command

keyword: string, character

property: caseSensitive

Compatibility and Support

Introduced

LiveCode 1.0

OS

mac

windows

linux

ios

android

Platforms

desktop

server

mobile

Thank you for your feedback!

Was this page helpful?